//
//  ViewController.m
//  TheRicher
//
//  Created by 李晓东 on 2018/1/12.
//  Copyright © 2018年 PeanutXu. All rights reserved.
//

#import "ViewController.h"
#import "R1Controller.h"
#import "R2Controller.h"
#import "R3Controller.h"
#import "R4Controller.h"
#import "R5Controller.h"
#import "R6Controller.h"
#import "R12Controller.h"
#import "R13Controller.h"
#import "R14Controller.h"
#import "R15Controller.h"
#import "R16Controller.h"
#import "R17Controller.h"
#import "R18Controller.h"
#import "R19Controller.h"
#import "R20Controller.h"
#import "R21Controller.h"
#import "R22Controller.h"
#import "R23Controller.h"
#import "R24Controller.h"
#import "R25Controller.h"
#import "R26Controller.h"
#import "R27Controller.h"
#import "R28Controller.h"
#import "R29Controller.h"
// 30 ~ 31
#import "R32Controller.h"

#import "TestController.h"
NSString * const CollectionCellId = @"HomeCellId";

@interface ViewController () <UICollectionViewDataSource, UICollectionViewDelegate>

@property (weak, nonatomic) IBOutlet UICollectionView *contentCollectionView;
@end

@implementation ViewController

- (void)loadView{
    [super loadView];
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
    [flowLayout setMinimumLineSpacing:5];
    [flowLayout setMinimumInteritemSpacing:20];
    [flowLayout setItemSize:CGSizeMake(80, 80)];
    [flowLayout setSectionInset:UIEdgeInsetsMake(0, 20, 0, 20)];
    [flowLayout setScrollDirection:UICollectionViewScrollDirectionVertical];
    [self.contentCollectionView setCollectionViewLayout:flowLayout];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.contentCollectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:CollectionCellId];
    [self.contentCollectionView setDataSource:self];
    [self.contentCollectionView setDelegate:self];
    
//    self.navigationControlle.
//    self.navigationController.automaticallyAdjustsScrollViewInsets = NO;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return 32;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CollectionCellId forIndexPath:indexPath];
    [cell setBackgroundView:[[UIImageView alloc]initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"%ld", indexPath.item]]]];
    [cell.layer setCornerRadius:8.0];
    [cell.layer setMasksToBounds:YES];
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewController *controller;
    TestController *testController;
    switch (indexPath.item) {
        case 0:
            controller = [[R1Controller alloc]init];
            [self.navigationController pushViewController:controller animated:YES];
//            [self presentViewController:controller animated:YES completion:nil];
            break;
        case 1:
            controller = [[R2Controller alloc]init];
            [self.navigationController pushViewController:controller animated:YES];
            break;
        case 2:
            controller = [[R3Controller alloc]init];
            [self.navigationController pushViewController:controller animated:YES];
            break;
        case 3:
            controller = [[R4Controller alloc]init];
            [self.navigationController pushViewController:controller animated:YES];
            break;
        case 4:
            controller = [[R5Controller alloc]init];
            [self.navigationController pushViewController:controller animated:YES];
            break;
        case 5:
            controller = [[R6Controller alloc]init];
            [self.navigationController pushViewController:controller animated:YES];
            break;
        case 6:
            controller = [[R6Controller alloc]init];
            [self.navigationController pushViewController:controller animated:YES];
            break;
        case 11:
            controller = [[R12Controller alloc]init];
            [self.navigationController pushViewController:controller animated:YES];
            break;
        case 12:
            controller = [[R13Controller alloc]init];
            [self.navigationController pushViewController:controller animated:YES];
            break;
        case 13:
            controller = [[R14Controller alloc]init];
            [self.navigationController pushViewController:controller animated:YES];
            break;
        case 14:
            controller = [[R15Controller alloc]init];
            [self.navigationController pushViewController:controller animated:YES];
            break;
        case 15:
            controller = [[R16Controller alloc]init];
            [self.navigationController pushViewController:controller animated:YES];
            break;
        case 16:
            controller = [[R17Controller alloc]init];
            [self.navigationController pushViewController:controller animated:YES];
            break;
        case 17:
            controller = [[R18Controller alloc]init];
            [self.navigationController pushViewController:controller animated:YES];
            break;
        case 18:
            controller = [[R19Controller alloc]init];
            [self.navigationController pushViewController:controller animated:YES];
            break;
        case 19:
            controller = [[R20Controller alloc]init];
            [self.navigationController pushViewController:controller animated:YES];
            break;
        case 20:
            controller = [[R21Controller alloc]init];
            [self.navigationController pushViewController:controller animated:YES];
            break;
        case 21:
            controller = [[R22Controller alloc]init];
            [self.navigationController pushViewController:controller animated:YES];
            break;
        case 22:
            controller = [[R23Controller alloc]init];
            [self.navigationController pushViewController:controller animated:YES];
            break;
        case 23:
            controller = [[R24Controller alloc]init];
            [self.navigationController pushViewController:controller animated:YES];
            break;
        case 24:
            controller = [[R25Controller alloc]init];
            [self.navigationController pushViewController:controller animated:YES];
            break;
        case 25:
            controller = [[R26Controller alloc]init];
            [self.navigationController pushViewController:controller animated:YES];
            break;
        case 26:
            controller = [[R27Controller alloc]init];
            [self.navigationController pushViewController:controller animated:YES];
            break;
        case 27:
            controller = [[R28Controller alloc]init];
            [self.navigationController pushViewController:controller animated:YES];
            break;
        case 28:
            controller = [[R29Controller alloc]init];
            [self.navigationController pushViewController:controller animated:YES];
            break;
        case 29:
//            controller = [[R30Controller alloc]init];
//            [self.navigationController pushViewController:controller animated:YES];
            break;
        case 30:
//            controller = [[R31Controller alloc]init];
//            [self.navigationController pushViewController:controller animated:YES];
            break;
        case 31:
            controller = [[R32Controller alloc]init];
            [self.navigationController pushViewController:controller animated:YES];
            break;
        default:
            testController = [[TestController alloc]init];
            [self.navigationController pushViewController:testController animated:YES];
            break;
    }
}

@end
